import request from '../../utils/request'

export function tableData<T>(data: unknown) {
  return request<List<T>>({
    url: '/black/object',
    method: 'POST',
    data
  })
}

export function save<T>(data: unknown) {
  return request<T>({
    url: '/black/object/modify',
    method: 'POST',
    data
  })
}

export function add<T>(data: unknown) {
  return request<T>({
    url: '/black/object/add',
    method: 'PUT',
    data
  })
}

export function deleteData<T>(id: string) {
  return request<T>({
    url: '/black/object/' + id,
    method: 'DELETE'
  })
}

export function exportData() {
  return request({
    url: '/template',
    method: 'POST',
    data: {
      type: 0
    },
    responseType: 'blob'
  })
}

export function upload<T>(data: unknown) {
  return request<T>({
    url: '/black/object/import',
    method: 'POST',
    data,
    requestType: 'blob'
  })
}
